<?
	include("cms.php");
	
	Cms::nocache();
	
	$precode = strtoupper(uniqid('a'));
	$precode = str_replace('0', 'Q', $precode);
	
	$code = substr($precode, strlen($precode) - 6, 5);
	
	$_SESSION['captcha'] = $code;
	
	$img = imagecreatetruecolor(50, 25);
	$bg = imagecolorallocate($img,0xFF, 0xFF, 0xFF);
	$tx = imagecolorallocate($img,0x00, 0x00, 0x00);
	imagefill($img, 0,0, $bg);
	imagestring($img, 4, 5, 3, $code, $tx);
	
	// Set the content type header - in this case image/jpeg
	header('Content-type: image/jpeg');
	
	// Output the image
	imagejpeg($img, NULL, 98);
	
	// Free up memory
	imagedestroy($img);
?>